<!DOCTYPE html>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <title>Ta的帖子</title>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">


    <link rel="stylesheet" href="/forum/css/main.min.css">
    <link rel="bookmark" type="image/x-icon" href="forum/images/favicon.ico">
    <link rel="shortcut icon" type="image/x-icon" href="/forum/images/favicon.ico">
    <link rel="stylesheet" href="/forum/css/personalProfile.css">
    <link rel="stylesheet" href="/forum/lib/layui/css/layui.css">
    <link rel="stylesheet" href="/forum/css/peoplehomepage.css">
    <link rel="stylesheet" href="/forum/css/mystyle.css">
    <script type="text/javascript" src="/forum/lib/jquery.min.js"></script>
    <style>
        .laypage_main a{width:auto;}
    </style>
</head>
<body>
<div id="body">

    <div th:replace="forum/header"></div>
    <!--*******************************-->
    <main class="main-wrapper">
        <div class="container-area">
            <div class="container-area-left">
                <!--头像 start-->
                <div class="card-media personal-card" th:style="${otherUser =='0'?'padding-bottom: 0px;':''}">
                    <div class="avatar-container-80 z-center">
                        <a th:href="@{'/forum/u/'+${userId}}" th:title="${userName}" class="author-avatar" target="_blank" >
                            <img th:src="${avatar}" width="80" height="80" th:title="${userName}" alt="">
                        </a>

                    </div>
                    <div class="presonal-info">
                        <a th:href="@{'/forum/u/'+${userId}}" class="author-name" target="_blank"
                           th:title="${userName}" z-st="user_card_1_name" th:text="${userName}"></a>
                    </div>
                    <div style="margin-top: 17px;margin-bottom: 13px;">
                        <table style="position: relative;margin: 0 auto;">
                            <tbody>
                            <tr>
                                <td>
                                    <strong><a href="javascipt:void(0);">[[${questionCount}]]</a></strong>
                                    <span style="font-size: 12px;color:#666;">帖子</span>
                                </td>
                                <td>|</td>
                                <td>
                                    <strong><a href="javascipt:void(0);">[[${look}]]</a></strong>
                                    <span style="font-size: 12px;color:#666;">访问</span>
                                </td>
                                <td>|</td>
                                <td>
                                    <strong><a href="javascipt:void(0);">[[${fansCount}]]</a></strong>
                                    <span style="font-size: 12px;color:#666;">粉丝</span>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>

                    <div class="btn-area" th:if="${loginUser ==null}">
                        <a onclick="addFocus(this)" th:data-userid="${userId}"  class="btn-default-main card-media-mid-btn">关 注</a><br />
                        <a onclick="sendMessage(this)" th:data-userid="${userId}"  style="margin-top: 8px;" class="btn-default-secondary card-media-mid-btn" >发私信</a><br />
                    </div>
                    <div class="btn-area"  th:if="${loginUser !=null}" th:style="${otherUser =='0'?'height: 80px;':''}">
                        <a href="/uploadQuestion" style="margin-top: 18px;"   th:if="${otherUser =='0'}" class="btn-default-main card-media-mid-btn">发 帖</a><br />
                        <a id="focusBtn" onclick="addFocus(this)"   th:data-userid="${userId}"  th:if="${otherUser =='1'}" class="btn-default-main card-media-mid-btn">关 注</a><br />
                        <a onclick="sendMessage(this)"  style="margin-top: 8px;"  th:data-userid="${userId}"   th:data-username="${userName}"  th:if="${otherUser =='1'}" class="btn-default-secondary card-media-mid-btn">发私信</a><br />
                    </div>
                    <div class="clear"></div>
                </div>
                <!--头像 end-->
                <div class="card-media personal-menu">

                    <ul class="menu-list">
                        <li class="menu-list-default ">
                            <i></i><a th:href="@{'/forum/u/'+${userId}}" id="left-data-account-focus">Ta的资料</a></li>
                    </ul>

                    <ul class="menu-list">
                        <li class="menu-list-default current"><i></i>
                            <a th:href="@{'/forum/taQuestion/'+${userId}}"  id="usercenter-menu-focus-left">Ta的帖子
                            </a>
                        </li>
                        <li class="menu-list-default ">
                            <i></i><a th:href="@{'/forum/taFocus/'+${userId}}">Ta的关注</a></li>
                    </ul>
                </div>

            </div>

            <div class="container-area-right">
                <div class="bg-box-radius">

                    <div class="tab-menu border-bottom">
                        <ul class="tab-box">
                            <li  class="current" ><a>Ta的帖子</a></li>
                        </ul>
                    </div>


                    <div class="datum-item-box border-bottom">
                        <table class="layui-table" lay-skin="line">
                            <colgroup>
                                <col width="36.666%">
                                <col width="19.999%">
                                <col width="23.665%">
                                <col width="8.666%">
                            </colgroup>
                            <thead>
                            <tr>
                                <th>标题</th>
                                <th>板块</th>
                                <th>时间</th>
                                <th>状态</th>
                            </tr>
                            </thead>
                            <tbody id="myList">

                            </tbody>
                        </table>
                        <div style="position:relative;bottom:0px;text-align: center;" id="pagebar" class="pagebar"></div>
                    </div>

                </div>

            </div>
        </div>
    </main>
    <div th:replace="forum/footer"></div>
</div>
<div class="shade hide"></div>

<script type="text/javascript" src="/forum/js/common.js"></script>
<script  th:src="@{/ruoyi/js/ry-ui.js}"></script>
<script th:inline="javascript"> var ctx = [[@{/}]];</script>
<script th:src="@{/ajax/libs/layer/layer.min.js}"></script>
<script th:src="@{/ruoyi/js/fast.js}"></script>
<script th:src="@{/ajax/libs/laypage/laypage.js}"></script>
<script>
    var userId='[[${userId}]]'
    var isLogin='[[${loginUser!=null}]]';
    var userFocusFlag='[[${focusFlag}]]';
    //关注用户
    function addFocus(obj){
        var focus_user_id=$(obj).data("userid");
        if(isLogin=='false'){
            openLoginWindow();
            return;
        }

        $.ajax({
            type: "post",
            url: ctx+"forumQuestion/addFocus/"+focus_user_id,
            data: null,
            xhrFields: {
                withCredentials: true
            },
            dataType: "json",
            success: function(data) {
                if(data.code==0||data.code=='0'){
                    Fast.msg_success("关注成功!");
                    $("#focusBtn").text("取消关注");
                    $("#focusBtn").removeAttr("onclick").attr("onclick","removeFocus(this)");
                }else{
                    Fast.msg_error(data.msg)
                }
            }
        })
    }
    function sendMessage(obj){
        var userid=$(obj).data("userid");
        if(isLogin=='false'){
            openLoginWindow();
            return;
        }

    }
    //取消关注
    function removeFocus(obj){
        if(isLogin=='false'){
            openLoginWindow();
            return;
        }
        var focus_user_id=$(obj).data("userid");
        $.ajax({
            type: "post",
            url: ctx+"forumQuestion/removeFocus/"+focus_user_id,
            data: null,
            xhrFields: {
                withCredentials: true
            },
            dataType: "json",
            success: function(data) {
                if(data.code==0||data.code=='0'){
                    Fast.msg_success("取消关注成功!");
                    $("#focusBtn").text("关 注");
                    $("#focusBtn").removeAttr("onclick").attr("onclick","addFocus(this)");
                }else{
                    Fast.msg_error(data.msg)
                }
            }
        })
    }
    $(function () {
        if(userFocusFlag=='true'){
            $("#focusBtn").text("取消关注").removeAttr("onclick").attr("onclick","removeFocus(this)");
        }else{
            $("#focusBtn").text("关 注").removeAttr("onclick").attr("onclick","addFocus(this)");
        }
        initTaQuestionList(1);
    })
    function initTaQuestionList(pageNum){

        $.ajax({
            type: "post",
            url: ctx+"forum/taQuestionList/"+userId,
            data: {"pageNum":pageNum},
            xhrFields: {
                withCredentials: true
            },
            dataType: "json",
            success: function(data) {

                if(data.code==0||data.code=='0'){
                    if(data.total>0){
                        var rows=data.rows;
                        var html='';
                        $.each(rows,function(index,row){

                            html+="<tr>";
                            html+='<td><a data-id="'+row.id+'" style="cursor: pointer;color:#00c1de;" onclick="viewRow(this)"  target="_blank">'+row.title+'</a></td>';
                            html+="<td>"+row.forumCategoryName+"</td>";
                            html+="<td>"+row.createTime+"</td>";

                            if(row.available==1){
                                html+="<td><span style=\"color:#1d94c7;\">正常</span></td>";
                            }else if(row.available==2){
                                html+="<td><span style=\"color:red;\">未通过</span></td>";
                            }else{
                                html+="<td><span style=\"color:gray;\">草稿</span></td>";
                            }
                           html+="</tr>";

                        });
                        $("#myList").html("");
                        $("#myList").append(html);

                        var totalPage = (data.total + 10 -1) / 10;
                        initPager(totalPage,pageNum);

                    }else{
                        $("#myList").html("<tr><td colspan=\"5\"   style='text-align: center'>暂无记录!</td></tr>");
                    }



                }
            }
        })
    }

    function initPager(totalPages,pageNum) {
        var $pagebar = $("#pagebar");
        laypage({
            cont: $pagebar, //容器。值支持id名、原生dom对象，jquery对象,
            pages: totalPages, //总页数
            curr: pageNum,
            jump:jumpPage,
            skin: '#1E9FFF',
            first: '首页', //若不显示，设置false即可
            last: '尾页', //若不显示，设置false即可
            prev: '上一页', //若不显示，设置false即可
            next: '下一页' //若不显示，设置false即可
        });
    }

    function jumpPage(obj,first){
        pageNo=obj.curr;
        if(!first){
            initTaQuestionList(pageNo);
        }
    }
    function viewRow(obj){
        var id=$(obj).data("id");
        window.top.location.href="/forum/question/questionDetail/"+id;
    }

</script>
</body>
</html>
